import {handleActions} from "redux-actions"
// 使用lodash
import _ from "lodash";



import{SECKILL_ADD_SECKILL} from "../types"
const InitialValue={
    // 商品id
    commodity_id:"619ee6d4ec8da821fc63fbe6",
    // 商品的名字
    name:"甜皮鸭",
    // 价格
    Price:"15",
    // 单用户限购数量
    restricted:"3",
    //销售总数 
    Total:"1000",
    // 已售总数
    Sold:"199",
    // 开始时间
    Start_time:(()=> {//获取当前时间
      let now= new Date();
      let _month = ( 10 > (now.getMonth()+1) ) ? '0' + (now.getMonth()+1) : now.getMonth()+1;
      let _day = ( 10 > now.getDate() ) ? '0' + now.getDate() : now.getDate();
      let _hour = ( 10 > now.getHours() ) ? '0' + now.getHours() : now.getHours();
      let _minute = ( 10 > now.getMinutes() ) ? '0' + now.getMinutes() : now.getMinutes();
      let _second = ( 10 > now.getSeconds() ) ? '0' + now.getSeconds() : now.getSeconds();
      return now.getFullYear() + '-' + _month + '-' + _day + ' ' + _hour + ':' + _minute + ':' + _second;
  })(),
    // 结束时间
    End_time:(()=> {//获取当前时间
      let now= new Date();
      let _month = ( 10 > (now.getMonth()+1) ) ? '0' + (now.getMonth()+1) : now.getMonth()+1;
      let _day = ( 10 > now.getDate() ) ? '0' + now.getDate() : now.getDate();
      let _hour = ( 10 > now.getHours() ) ? '0' + now.getHours() : now.getHours();
      let _minute = ( 10 > now.getMinutes() ) ? '0' + now.getMinutes() : now.getMinutes();
      let _second = ( 10 > now.getSeconds() ) ? '0' + now.getSeconds() : now.getSeconds();
      return now.getFullYear() + '-' + _month + '-' + _day + ' ' + _hour + ':' + _minute + ':' + _second;
  })(),
    // 活动类型
    Sale_type:"普通",
    // 是否在售
    State:"1" ,
    rows:[]
}

export const seckill_add=handleActions({
    // 将传入的数据存储到状态机
    [SECKILL_ADD_SECKILL]:(state,{payload})=>{
        const {data}=payload
        console.log(data);
      return  _.assign({},state,data)
    },
 },InitialValue)